/*!
 * \autor captainpeng
 * \date 2019-9-30
 * \version 1.0
 * \copyright
 */

#include<iostream>
#include<my.hpp>

int main(){
    using namespace std;
    using namespace my;

    // utf8 to unicode 测试开始
    unicode test;
    // 0 ,test == 0x61
    std::string str("a");
    
    test = utf8::StrToUnicode(str);
    cout<<hex<<str<<":"<<test<<endl;

    // c0 .. df ,test == 0xA9
    str = "©";

    test = utf8::StrToUnicode(str);
    cout<<hex<<str<<":"<<test<<endl;

    // e0 .. ef ,test == 0x2260 中文集中在这里，这里测试通过
    str = "≠";

    test = utf8::StrToUnicode(str);
    cout<<hex<<str<<":"<<test<<endl;

    // 中文测试"啊"， test == 554a
    str = "啊";

    test = utf8::StrToUnicode(str);
    cout<<hex<<str<<":"<<test<<endl;
    
    // f8 .. fb ,test == 0x1f642
    str = "🙂";

    test = utf8::StrToUnicode(str);
    cout<<hex<<str<<":"<<test<<endl;

    // fc .. fd ,test == 0x200100 过大，已经没有测的必要性
    // str = "";

    // test = Str2Unicode(str);
    // cout<<hex<<str<<":"<<test<<endl;

    // utf8 to unicode 测试结束
    // 输出字符 a
    test = 0x61;
    cout<<utf8::UnicodeToStr(test)<<endl;

    // 输出字符 ©
    test = 0xa9;
    cout<<utf8::UnicodeToStr(test)<<endl;

    // 输出字符 ≠
    test = 0x2260;
    cout<<utf8::UnicodeToStr(test)<<endl;
    
    // 输出字符 啊
    test = 0x554a;
    cout<<utf8::UnicodeToStr(test)<<endl;

    // 输出字符 🙂
    test = 0x1f642;
    cout<<utf8::UnicodeToStr(test)<<endl;    
    // unicode to utf8 测试结束

    // string to unicode vector 测试开始
    // vec = {0x61, 0xa9, 0x2260, 0x554a, 0x1f642}
    str = "a©≠啊🙂";
    std::vector<unicode> vec;
    vec = utf8::StrToUnicodeVec(str);
    cout<<"{";
    for(auto it = vec.begin(); it != vec.end(); ++it)
        cout<<hex<<(*it)<<",";
    cout<<"}"<<endl;
    
    // string to unicode vector 测试结束
    // unicode vector to string 测试开始
    // str = "a©≠啊🙂"
    str = utf8::UnicodeVecToStr(vec);
    cout<<str<<endl;
    // unicode vector to string 测试结束
    return 0;
}
